/*
 * Copyright (c) 2016 zhangcm. All Rights Reserved.
 */
package com.jnzc.ocr.common.utils;

import com.google.common.base.Preconditions;
import com.jnzc.ocr.common.consts.ErrorConsts;
import com.jnzc.ocr.common.error.BusinessException;

/**
 * @author zhangcm
 * @version 1.0, 2017/8/27
 */
public class BusinessUtils {

    private BusinessUtils(){}

    public static void isNull(Object data, String messgae){
        Preconditions.checkNotNull(messgae);
        if(null != data){
            throw new BusinessException(ErrorConsts.BUSINESS, messgae);
        }
    }

    public static void notNull(Object data, String messgae){
        Preconditions.checkNotNull(messgae);
        if(null == data){
            throw new BusinessException(ErrorConsts.BUSINESS, messgae);
        }
    }

    public static void isTrue(Boolean data, String messgae){
        Preconditions.checkNotNull(data);
        Preconditions.checkNotNull(messgae);
        if(!data){
            throw new BusinessException(ErrorConsts.BUSINESS, messgae);
        }
    }

    public static void throwException(String messgae){
        Preconditions.checkNotNull(messgae);
        throw new BusinessException(ErrorConsts.BUSINESS, messgae);
    }
}
